<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <a href="http://baidu.com" id="links">百度</a>
</body>
<Script>
    var links = document.getElementById("links");
    links.onclick = function(e){
        //通过事件对象调用preventDefault（）来
        // 阻止元素的默认操作，比如超链接的跳转
        e.preventDefault();
    }
</Script>
</html>